<?php
declare (strict_types = 1);

namespace app\model\mysql;

use think\Model;

class ProductSpec extends Model {

    protected $hidden = ["is_delete"];

    protected $name = "product_spec";

    protected $createTime = "created_time";

    protected $updateTime = "updated_time";

    protected $autoWriteTimestamp = true;


    public function getList($field = "id, name") : array {

        $result = $this->where("is_delete", "<>", 1)
            ->field($field)->select();

        return $result ? $result->toArray() : [];
    }

    public function isExist($id = 0) : bool {
        if ($id <= 0) {
            return false;
        }
        $result = $this->where("is_delete", "<>", 1)->find($id);

        return $result && $result->id > 0 ? true : false;
    }
}